###
 # @file hmemo/test/code_coverage.sh
 #
 # @license
 # Copyright (c) 2009-2018
 # Fraunhofer Institute for Algorithms and Scientific Computing SCAI
 # for Fraunhofer-Gesellschaft
 #
 # This file is part of the SCAI framework LAMA.
 #
 # LAMA is free software: you can redistribute it and/or modify it under the
 # terms of the GNU Lesser General Public License as published by the Free
 # Software Foundation, either version 3 of the License, or (at your option)
 # any later version.
 #
 # LAMA is distributed in the hope that it will be useful, but WITHOUT ANY
 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
 # more details.
 #
 # You should have received a copy of the GNU Lesser General Public License
 # along with LAMA. If not, see <http://www.gnu.org/licenses/>.
 # @endlicense
 #
 # @brief This file is a shellscript, which contains all necessary steps to 
 #        measure code coverage of LAMA subproject hmemo
 # @author Lauretta Schubert
 # @date 15.08.2012
###

source scai_code_coverage_functions.sh

# Check requirements for codecoverage
requirements_coverage

dirname=$(create_dir)
echo "Create coverage directory: ${dirname}"

prepare_coverage $dirname ../..

export SCAI_LOG=TRACE
export SCAI_TRACE=time
	
# Running tests serial
echo "Running hmemo tests on Host"
count_error ./hmemoTest --SCAI_CONTEXT=Host

if [ -d cuda ];
then
	#Running CUDA tests
	echo "Running hmemo tests with CUDA context"
	count_error ./hmemoTest --SCAI_CONTEXT=CUDA
	echo "Running hmemo CUDA tests"
	count_error ./cuda/hmemoCUDATest
fi

exit_on_failure ${error_count}

do_coverage $dirname ../.. "@CMAKE_SOURCE_DIR@/@MODULE_NAME@"

exit_on_failure $?

zip -qr ../hmemo_coverage.zip *
